package quick.start.core.view;

import android.os.Bundle;
import android.support.v4.app.Fragment;

public abstract class SweetFragment extends Fragment {

	protected RequestProxy mRequestProxy;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (mRequestProxy == null) {
            mRequestProxy = createRequestProxy();
        }
        mRequestProxy.loadInstanceState(savedInstanceState);
    }

    

    @Override
    public void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        mRequestProxy.saveInstanceState(outState);
    }

    @Override
    public void onResume() {
        super.onResume();
        mRequestProxy.loadRequestList();
    }

    @Override
    public void onPause() {
        super.onPause();
        mRequestProxy.removeRequestListener();
    }
    
    protected abstract RequestProxy createRequestProxy();
}
